----------------------------------------------------------------------------------------------------------------------------------
--[[

    晾晒模块

    self.drying_data = {
        harvest = "prefab_or_index", -- 收获物 的函数。
        userid = "userid", -- 用户id    --- 特定目标可用
        accept = {  -- 可接受的物品 + 文本
            ["prefab"] = STRINGS.ACTIONS.ACTIVATE.ACCOMPLISH,
        },
    },

]]--
----------------------------------------------------------------------------------------------------------------------------------
local hutao_com_drying_module = Class(function(self, inst)
    self.inst = inst

    self.drying_data = {}
    self.__drying_data_str = net_string(inst.GUID,"drying_data_update","drying_data_update")
    if not TheNet:IsDedicated() then
        inst:ListenForEvent("drying_data_update",function()
            local str = self.__drying_data_str:value()
            local flag,_table = pcall(json.decode,str)
            if flag then
                self.drying_data = _table
            end
        end)
    end
end)
------------------------------------------------------------------------------------------------------------------------------
-- 物品接受
    function hutao_com_drying_module:GetAcceptting()
        return self.drying_data.accept or {}        
    end
    function hutao_com_drying_module:CanAccept(prefab)
        if self.inst:HasTag("burnt") then
            return false,""
        end
        local acceptting = self:GetAcceptting()
        if acceptting[prefab] then
            return true,( acceptting[prefab] or "")
        end
        return false,""
    end
------------------------------------------------------------------------------------------------------------------------------
--
    function hutao_com_drying_module:CanHarvest(doer)
        if self.inst:HasTag("burnt") then
            return false
        end
        if self.drying_data.harvest == nil then
            return false
        end
        if self.drying_data.userid  == nil then
            return true
        end
        if self.drying_data.userid == doer.userid then
            return true
        end
        return false
    end
------------------------------------------------------------------------------------------------------------------------------
--
    function hutao_com_drying_module:GetCurrent()
        return self.drying_data.harvest
    end
------------------------------------------------------------------------------------------------------------------------------
--
    function hutao_com_drying_module:SetData(_table)
        if TheWorld.ismastersim then
            local str = json.encode(_table)
            self.__drying_data_str:set(str)
            self.drying_data = _table
        end
    end
------------------------------------------------------------------------------------------------------------------------------
return hutao_com_drying_module







